package com.example.administrator.basedemos.SingleInstance;

/**
 * 创建者     ZCL
 * 创建时间   2018/10/9 13:53
 * 描述	      ${TODO}
 * <p>
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述   ${TODO}
 */
public class MySingleInstance {

    private static SingleInstanceT mInstanceT;

    public MySingleInstance() {//饿汉
        mInstanceT = new SingleInstanceT();
    }
    public static SingleInstanceT getmInstanceT() {
        return mInstanceT;
    }


    public static SingleInstanceT getmInstanceTL() {
        if (mInstanceT == null)
            synchronized (MySingleInstance.class) {//懒汉
                if (mInstanceT == null)
                    mInstanceT = new SingleInstanceT();
            }
        return mInstanceT;
    }

    private static class SingleHolder{//内部类
        /**
         * 静态初始化 由JVM保证线程安全
         */
        private static SingleInstanceT mSingleHolder = new SingleInstanceT();
    }
    public static SingleInstanceT getInstance(){
        return SingleHolder.mSingleHolder;
    }

}
